//
//  SpriteKitMainViewController.swift
//  SpriteKitDemo
//
//  Created by lizhijun on 2023/4/18.
//

import UIKit
import SpriteKit
class SpriteKitMainViewController: UIViewController {
    private lazy var skView :SKView = {
        let view = SKView(frame: CGRect(x: 0, y: 0, width: SCREENW, height: SCREENH))
        return view
    }()
    private lazy var scene :SKMainScene = {
        let scene = SKMainScene(size: CGSize(width: SCREENW, height: SCREENH))
        scene.scaleMode = .aspectFill
        return scene
    }()
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white
        setupUI()
        
    }
    
    private func setupUI(){
        //self.scene.contentView代替self.skView
        //self.view.addSubview(self.skView)
        self.view.addSubview(self.scene.contentView)
        
        //Create and configure the scene
        self.skView.presentScene(self.scene)
        scene.setUpUI()
    }
   
}

